package greetingtest;

import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.rpc.Call;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceFactory;

public class DynamicInvocationTest {
	public static void main(String[] argv) throws Exception {
		try {
			ServiceFactory factory = ServiceFactory.newInstance();
			// Lookup Service. . Service is entry point for a web service.
		
			Service service = factory.createService(new URL(
					"http://localhost:8080/myws/GreetingWebService?wsdl"), new QName(
					"http://webservice.hanbo.tutorial/", "GreetingService"));
			
			// A webservice can have different port. Port is like a library of
			// methods.
			// Set the location of wsdl.
			
			Call call = service.createCall(new QName("http://webservice.hanbo.tutorial/",
					"GreetingPort"), new QName("http://webservice.hanbo.tutorial/",
							"greetClient"));
			

			Object[] params = { "Titi" };
			String result = (String) call.invoke(params);
			System.out.println(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
